//
//  AXFLaunchViewController.m
//  AIXF
//
//  Created by zhanghui on 2017/7/9.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "AXFLaunchViewController.h"
#import "AXFLaunchCell.h"

@interface AXFLaunchViewController ()<UICollectionViewDataSource>

@property (nonatomic,strong) NSArray *launchAdArr;

@property (strong,nonatomic)UICollectionView *collection;

@end

@implementation AXFLaunchViewController

static NSString * const reuseIdentifier = @"Cell";



- (void)viewDidLoad {
    [super viewDidLoad];
    

    [self setCollectionView];
    
    
}

#pragma mark - 初始化collection
- (void)setCollectionView{
 
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    flowLayout.itemSize = self.view.bounds.size;
    
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.minimumInteritemSpacing = 0;
    
    self.collection = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
    
    self.collection.pagingEnabled = YES;
    self.collection.bounces = NO;
    self.collection.showsHorizontalScrollIndicator = NO;
    
     //注册cell
    [self.collection registerNib:[UINib nibWithNibName:@"AXFLaunchCell" bundle:nil] forCellWithReuseIdentifier:reuseIdentifier];
    
    //设置数据源
    self.collection.dataSource = self;
    
    [self.view addSubview:self.collection];
    
}



- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return self.launchAdArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    AXFLaunchCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    
    if (indexPath.item == self.launchAdArr.count -1) {
        
        cell.enterTabCtrButton.hidden = NO;
    }
    
    
    cell.imageName = self.launchAdArr[indexPath.row];
    
    return cell;
}

#pragma mark - 懒加载数据模型
- (NSArray *)launchAdArr{
    
    if (!_launchAdArr) {
        
        NSMutableArray *arrM = [NSMutableArray array];
        
        for (NSInteger i = 0; i < 4; i++) {
            
            NSString *imageName = [NSString stringWithFormat:@"guide_40_%zd",i+1];
            
            [arrM addObject:imageName];
        }
        
        _launchAdArr = arrM;
    }
    
    return _launchAdArr;
    
}






@end
